package com.happe.foodeasy.normal.entity;

import com.happe.foodeasy.dto.CustomerDTO;

import java.util.Date;

/**
 * This entity is corresponding CustomerEntity that will buy goods in
 * website.
 * Created by wubin on 2016-04-02.
 */
public class CustomerEntity extends CommonInfoEntity {
    private String username;
    private String password;
    private String phone;
    private boolean verifyPhoneFlag;
    private boolean storeBossFlag;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public boolean isVerifyPhoneFlag() {
        return verifyPhoneFlag;
    }

    public void setVerifyPhoneFlag(boolean verifyPhoneFlag) {
        this.verifyPhoneFlag = verifyPhoneFlag;
    }

    public boolean isStoreBossFlag() {
        return storeBossFlag;
    }

    public void setStoreBossFlag(boolean storeBossFlag) {
        this.storeBossFlag = storeBossFlag;
    }

    public static CustomerEntity newInstanceFromDTO(CustomerDTO customerDTO) {
        CustomerEntity customer = new CustomerEntity();
        customer.setUsername(customerDTO.getUsername());
        customer.setPassword(customerDTO.getPassword());
        customer.setPhone(customerDTO.getPhone());
        customer.setVerifyPhoneFlag(true);
        customer.setStoreBossFlag(false);
        customer.setCreateTime(new Date());
        customer.setValidityFlag(true);
        return customer;
    }
}
